﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ymatou.ServiceCenter.Common.Extensions
{
    public static class ValueTypeExtensions
    {
        public static bool IsEmpty<T>(this T value) where T : struct
        {
            return value.Equals(default(T));
        }

        public static bool IsNotEmpty<T>(this T value) where T : struct
        {
            return (value.IsEmpty() == false);
        }

        public static T? ToNullable<T>(this T value) where T : struct
        {
            return (value.IsEmpty() ? null : (T?)value);
        }
    }
}
